//
//  MeatOrderTimerCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/27.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatOrderTimerCell.h"

@interface MeatOrderTimerCell()

@end

@implementation MeatOrderTimerCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    [self addSubview:self.priceLab];
    [self addSubview:self.shiLab];
    [self addSubview:self.fenLab];
    [self addSubview:self.miaoLab];
    [self addSubview:self.signLab];
    
}

- (void)setupLayout{
    
    {
        _priceLab.size = CGSizeMake(KScreenWidth - 30, 23);
        _priceLab.mj_x = 15;
        _priceLab.mj_y = 17;
    }
    
    {
        _signLab.frame = CGRectMake(0, 0, KScreenWidth, 30);
        [_signLab sizeToFit];
        _signLab.mj_y = 46;
        _signLab.mj_x = KScreenWidth/2.0 - _signLab.width;
    }
    
    {
        _shiLab.size = _fenLab.size = _miaoLab.size = CGSizeMake(20, 17);
        _shiLab.mj_x = _signLab.right + 4;
        _shiLab.mj_y = _fenLab.mj_y = _miaoLab.mj_y = _priceLab.bottom + 5;
        _fenLab.mj_x = _shiLab.right + 15;
        _miaoLab.mj_x = _fenLab.right + 15;
    }
    
    for (NSInteger i = 0; i< 2; i++) {
        UILabel *label = [UILabel makeLabelWithText:@":" textColor:UIColorFromRGB(0x333333) font:mFont(14) textAliment:1];
        label.size = CGSizeMake(15, 17);
        label.mj_y = _shiLab.mj_y;
        label.mj_x = _shiLab.right + (_shiLab.width + label.width)*i;
        [self addSubview:label];
    }
    
    
}

#pragma mark - setter methods
- (void)setPrice:(NSString *)price{
    
    NSString *text = [NSString stringWithFormat:@"¥%@", price];
    
    NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]initWithString:text];
    [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xF25C62) range:NSMakeRange(0, text.length)];
    [attributedString addAttribute:NSFontAttributeName value:mBlodFont(12) range:NSMakeRange(0, text.length)];
    [attributedString addAttribute:NSFontAttributeName value:mBlodFont(19) range:NSMakeRange(1, text.length - 4)];
    _priceLab.attributedText = attributedString;

}


#pragma mark - getter methods

- (UILabel *)signLab{
    
    if (!_signLab) {
        _signLab = [UILabel makeLabelWithText:@"支付剩余时间" textColor:UIColorFromRGB(0x666666) font:mFont(11) textAliment:2];
    }
    return _signLab;
}

- (UILabel *)shiLab{
    
    if (!_shiLab) {
        _shiLab = [UILabel makeLabelWithText:@"00" textColor:UIColorFromRGB(0x666666) font:mFont(12) textAliment:1];
        _shiLab.backgroundColor = UIColorFromRGB(0xDCDCDC);
    }
    return _shiLab;
}

- (UILabel *)fenLab{
    
    if (!_fenLab) {
        _fenLab = [UILabel makeLabelWithText:@"00" textColor:UIColorFromRGB(0x666666) font:mFont(12) textAliment:1];
        _fenLab.backgroundColor = UIColorFromRGB(0xDCDCDC);

    }
    return _fenLab;
}

- (UILabel *)miaoLab{
    
    if (!_miaoLab) {
        _miaoLab = [UILabel makeLabelWithText:@"00" textColor:UIColorFromRGB(0x666666) font:mFont(12) textAliment:1];
        _miaoLab.backgroundColor = UIColorFromRGB(0xDCDCDC);
    }
    return _miaoLab;
}


- (UILabel *)priceLab{
    
    if (!_priceLab) {
        _priceLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0xF25C62) font:mFont(17) textAliment:1];
    }
    return _priceLab;
}


@end
